package com.yuliang.controller;



import com.yuliang.domain.R;
import com.yuliang.domain.dto.AddUserDto;
import com.yuliang.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/system/user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/list")
    public R userPageList(Integer pageNum,Integer pageSize,String userName,String phonenumber,String status){
        return userService.userPageList(pageNum,pageSize,userName,phonenumber,status);
    }

    @PostMapping
    public R addUser(@RequestBody AddUserDto addUserDto){
        return userService.addUser(addUserDto);
    }

    @DeleteMapping("/{id}")
    public R deleteUser(@PathVariable("id") List<Long> ids){
        return userService.deleteUser(ids);
    }

    @GetMapping("/{id}")
    public R getUserDetail(@PathVariable("id") Long id){
        return userService.getUserDetail(id);
    }

    @PutMapping
    public R updateUser(@RequestBody AddUserDto addUserDto){
        return userService.updateUser(addUserDto);
    }
}
